/*** 本文件由HaivDb4J2ee工具辅助生成，版本1.3.1 ***/

package com.ce.sys.dict.logic.search;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.ce.framework.datamaintain.logic.ISQLMapper;
import com.ce.framework.datamaintain.logic.SQLSearchCondition;
import com.ce.framework.exception.AppException;
import com.ce.framework.util.StringUtil;
import com.ce.sys.dict.view.SysDictMView;

/**
* 嫦娥软件有限公司 版权所有 2013
* 创建人：　andy
* 创建日期：2010-09-14
* 创建时间：09:47:42
* 功能描述：字典主表 [SYS_T_DICT$M]条件过滤类
* ==============================================
* 修改历史
* 修改人		修改时间		修改原因
*
* ==============================================
*/
public class SysDictMSearchCondition  extends SQLSearchCondition
	implements ISQLMapper
{
	private String names;
	
	public String getSearchSql() throws AppException {
		
		String sql = "select * from SYS_T_DICT$M t where t.VC_DEL$FLAG = 0 ";
		if(StringUtil.isNotBlank(this.names)){
			sql = sql + " and t.VC_NAME like '%"+this.getSafeValue(this.names)+"%'";
		}
		if(StringUtil.isNotBlank(this.order)){
			if(StringUtil.isNotBlank(this.sort)&&"nseq".equals(this.sort))
				sql = sql + "order by t.N_SEQ "+this.order;
			if(StringUtil.isNotBlank(this.sort)&&"vcName".equals(this.sort))
				sql = sql + "order by t.VC_NAME "+this.order;
		}else{
			sql = sql + "order by t.vc_name,t.N_SEQ asc , t.DT_CREATE desc";
		}
		return sql;
	}
	
	public Object fromSQLQuery(ResultSet rs, int num) {
		SysDictMView view = new SysDictMView();
		try {
			view.setVcId(rs.getString("VC_ID"));
			view.setVcName(rs.getString("VC_NAME"));
			view.setVcFlag(rs.getString("VC_FLAG"));
			view.setVcNote(StringUtil.isBlank(rs.getString("VC_NOTE"))?"":rs.getString("VC_NOTE"));
			view.setVcOrgId(rs.getString("VC_ORG$ID"));
			view.setVcOrgFlag(rs.getString("VC_ORG$FLAG"));
			view.setNseq(rs.getInt("N_SEQ"));
			view.setVcUrl(rs.getString("VC_URL"));
			view.setDtCreate(rs.getDate("DT_CREATE"));
			view.setVcDelFlag(rs.getInt("VC_DEL$FLAG"));			

		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		return view;
	}
	
	public ISQLMapper getSQLMapper() {
		
		return this;
	}

	public String getNames() {
		return names;
	}

	public void setNames(String names) {
		this.names = names;
	}

}

